begin 

   yy = getenv("yy")

   ;;...................................................... 
   ;; Input files 
   ;;...................................................... 
   fna = "emis_GFED3.1_daily_BC_"+yy+"_2x2.5.nc"
   fnb = "emis_GFED3.1_daily_OC_"+yy+"_2x2.5.nc"
   fnc = "ar5_mam3_num_a1_elev_2000_c090726.nc"
   fno = "emis_BCOC_GFED3.1_daily_num_a1_"+yy+"_2x2.5.nc"

   fla = addfile(fna,"r") 
   flb = addfile(fnb,"r") 
   flc = addfile(fnc,"r") 

   BC_fire = fla->BC_fire 
   OC_fire = flb->OC_fire 

   lat = fla->lat
   lon = fla->lon
   date = fla->date
   altitude = fla->altitude
   altitude_int = fla->altitude_int

   ;;...................................................... 
   ;; output number data 
   ;;...................................................... 

   factor_BC = 1.7848e-19 
   factor_OC = 7.4990e-20

   print("output file : "+fno)
   print(" ")
   print(" ")

   system("rm "+fno)

   flo = addfile(fno,"c")

   BC_fire = BC_fire / factor_BC  
   OC_fire = OC_fire / factor_OC 

   v1 = flc->SO4_emiss_ene
   v2 = flc->SO4_emiss_ind
   v3 = flc->SO4_forestfire
   v4 = flc->SO4_grassfire
   v5 = flc->SO4_contvolc

   vv1 = BC_fire
   vv2 = BC_fire
   vv3 = BC_fire
   vv4 = BC_fire
   vv5 = BC_fire

   vv1@long_name = v1@long_name 
   vv2@long_name = v2@long_name 
   vv3@long_name = v3@long_name 
   vv4@long_name = v4@long_name 
   vv5@long_name = v5@long_name 

   vv1@units = v1@units 
   vv2@units = v2@units 
   vv3@units = v3@units 
   vv4@units = v4@units 
   vv5@units = v5@units 

   ;;......................................................
   ;; vertical profile remapping
   ;;......................................................

   idx = (/1,  32, 60, 91,  121, 152, 182, 213, 244, 274, 305, 335 /)
   idy = (/31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 /)
   
   idd = idy - idx 
   
   print("nday in mon : "+ idd) 
   print(" ") 
   print(" ") 

   do im = 0, 11 
      ida = idx(im)
      idb = idy(im) 
      print("imon, ida, idb, id : "+im+" "+ida+"   "+idb)
      vv1(ida:idb,:,:,:) = conform(vv1(ida:idb,:,:,:), v1(im,:,:,:), (/1,2,3/) )
      vv2(ida:idb,:,:,:) = conform(vv2(ida:idb,:,:,:), v2(im,:,:,:), (/1,2,3/) )
      vv3(ida:idb,:,:,:) = conform(vv3(ida:idb,:,:,:), v3(im,:,:,:), (/1,2,3/) )
      vv4(ida:idb,:,:,:) = conform(vv4(ida:idb,:,:,:), v4(im,:,:,:), (/1,2,3/) )
      vv5(ida:idb,:,:,:) = conform(vv5(ida:idb,:,:,:), v5(im,:,:,:), (/1,2,3/) )
   end do
   
   vv1(0,:,:,:)   = (/ v1(11,:,:,:)  /)
   vv1(366,:,:,:) = (/ v1(0,:,:,:)  /)
   
   vv2(0,:,:,:)   = (/ v2(11,:,:,:)  /)
   vv2(366,:,:,:) = (/ v2(0,:,:,:)  /)
   
   vv3(0,:,:,:)   = (/ v3(11,:,:,:)  /)
   vv3(366,:,:,:) = (/ v3(0,:,:,:)  /)
   
   vv4(0,:,:,:)   = (/ v4(11,:,:,:)  /)
   vv4(366,:,:,:) = (/ v4(0,:,:,:)  /)
   
   vv5(0,:,:,:)   = (/ v5(11,:,:,:)  /)
   vv5(366,:,:,:) = (/ v5(0,:,:,:)  /)

   flo->BC_fire=BC_fire
   flo->OC_fire=OC_fire
   flo->SO4_emiss_ene=vv1
   flo->SO4_emiss_ind=vv2
   flo->SO4_forestfire=vv3
   flo->SO4_grassfire=vv4
   flo->SO4_contvolc=vv5
   flo->lat=lat
   flo->lon=lon
   flo->date=date
   flo->altitude=altitude
   flo->altitude_int=altitude_int

   ;;......................................................
   ;; create global attributes of the file
   ;;......................................................
   fAtt               = True            
   fAtt@Author        = "Kai Zhang (kai.zhang@pnnl.gov)"
   fAtt@Source        = "GFED3.1 fire emission data and CAM5 input files"
   fAtt@creation_date = systemfunc ("date")
   fileattdef( flo, fAtt )

end



